import random

# 生成中奖号码
winning_numbers = sorted(random.sample(range(1, 34), 8))
print("本期中奖号码为：", winning_numbers)

# 用户输入号码
user_input = input("请输入8个1-33的数字，用空格分隔：")
user_numbers = list(map(int, user_input.split()))
print("您输入的号码为：", user_numbers)

# 检查中奖等级
match_count = len(set(user_numbers) & set(winning_numbers))  # 计算匹配数量
if match_count == 8:
    prize = "一等奖"
elif match_count == 7:
    prize = "二等奖"
elif match_count == 6:
    prize = "三等奖"
elif match_count == 5:
    prize = "四等奖"
else:
    prize = "未中奖"
print("您的中奖结果为：", prize)

# 模拟10000注彩票
target_numbers = [1, 2, 3, 4, 5, 6, 7, 8]  # 假设特定号码为1,2,3,4,5,6,7,8
prize_probabilities = {"一等奖": 0, "二等奖": 0, "三等奖": 0, "四等奖": 0, "未中奖": 0}

for _ in range(10000):
    winning_numbers = sorted(random.sample(range(1, 34), 8))
    match_count = len(set(target_numbers) & set(winning_numbers))
    if match_count == 8:
        prize_probabilities["一等奖"] += 1
    elif match_count == 7:
        prize_probabilities["二等奖"] += 1
    elif match_count == 6:
        prize_probabilities["三等奖"] += 1
    elif match_count == 5:
        prize_probabilities["四等奖"] += 1
    else:
        prize_probabilities["未中奖"] += 1

# 计算概率
for prize in prize_probabilities:
    prize_probabilities[prize] /= 10000

# 输出概率
print("\n模拟10000注彩票对特定号码的中奖概率...")
for prize, probability in prize_probabilities.items():
    print(f"{prize}: {probability * 100:.2f}%")